//
//  YDAWeekNewModel.m
//  siyanone
//
//  Created by LK-IOS on 2018/3/21.
//  Copyright © 2018年 LK-News. All rights reserved.
//

#import "YDAWeekNewModel.h"

@implementation YDAWeekNewModel


+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{
             @"Id" : @"id"
             };
}


-(NSString *)formateTime
{
    
    NSDateFormatter *formate = [[NSDateFormatter alloc] init];
    [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *date = [formate dateFromString:self.createTime];
    
    NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
    [formate1 setDateFormat:@"yyyy.MM.dd HH:mm"];
    return [formate1 stringFromDate:date];
}


//默认三行的高度
-(CGFloat)titleDefaultH
{
    return [NSString getWrapSpaceLabelHeight:@"时时时" withFont:[UIFont systemFontOfSize:font14ScreenWRate * LKScreenW] withWidth:200 andWrapSpace:0.3 withSpace:1.2] * 3;
}
-(NSAttributedString *)attrTitle
{
    return [NSString createLineWrapAttriStringWithString:self.title andLineSpace:1.2 withWrapSpace:0.3 Font:[UIFont systemFontOfSize:font14ScreenWRate * LKScreenW]];
}

-(CGFloat)cellH
{
    CGFloat marginTB = isPhoneX ? rateX812(5) : rate750(5);//上线间距
    CGFloat marginLR = rate375(7);
    
    //背景及图片
    CGFloat backX = marginLR;
    CGFloat backY = marginTB;
    CGFloat backW = LKScreenW - marginLR * 2;
    
    CGFloat imageX = backX + marginLR;
    CGFloat imageY = backY + marginLR;
    CGFloat imageW = rate375(128);
    CGFloat imageH = isPhoneX ? rateX812(90) : rate750(90);
    
    _imageFrame = CGRectMake(imageX, imageY, imageW, imageH);
    CGFloat backH = CGRectGetMaxY(_imageFrame) + marginLR;
    _backFrame = CGRectMake(backX, backY, backW, backH);
    
    
    //标题
    CGFloat titleX = CGRectGetMaxX(_imageFrame) +marginLR;
    CGFloat titleY = imageY;
    CGFloat titleW = CGRectGetMaxX(_backFrame) - titleX - marginLR;
    
    CGFloat calH = [NSString getWrapSpaceLabelHeight:self.title withFont:[UIFont systemFontOfSize:font14ScreenWRate * LKScreenW] withWidth:titleW andWrapSpace:0.3 withSpace:1.2];
    
    if (calH <= self.titleDefaultH) {
        _titleFrame = CGRectMake(titleX, titleY, titleW, calH);
    }else{
        _titleFrame = CGRectMake(titleX, titleY, titleW, self.titleDefaultH);
    }
    
    //时间
    CGSize timeSize = [NSString sizeWithText:self.formateTime font:[UIFont systemFontOfSize:font10ScreenWRate * LKScreenW] maxSize:CGSizeMake(300, 50)];
    CGFloat timeX = CGRectGetMaxX(_titleFrame) - timeSize.width;
    CGFloat timeW = timeSize.width;
    CGFloat timeH = timeSize.height;
    CGFloat timeY = CGRectGetMaxY(_imageFrame) - timeH;
    
    _timeFrame = CGRectMake(timeX, timeY, timeW, timeH);
    
    
    return CGRectGetMaxY(_backFrame) + marginTB;
}

@end
